
$script(window.global.plugin+'/tool/ua-parser/src/ua-parser.js','ua-parser', function() {
	var parser = new UAParser();
	$("#indexContent").html(parser.getResult());
});
function detectBrowser() {
	var browser = navigator.appName
	var b_version = navigator.appVersion
	var version = parseFloat(b_version)
	alert(browser+":"+b_version+":"+version);
	if ((browser == "Netscape" || browser == "Microsoft Internet Explorer")
			&& (version >= 4)) {
		alert("Your browser is good enough!")
	} else {
		alert("It's time to upgrade your browser!")
	}
} 
indexPageContext = new PageContext(index_settings ||{});
jQuery(function($) {
	//websocket
//	var socket = new Connect({host:"127.0.0.1:81",domain:window.global.ctx+"/ws"});
//	socket.connectAfter = function(frame){
//		console.log('Connected: ' + frame);
//		socket.send("/app/hello", {}, JSON.stringify({'name':"d"}))
//		socket.subscribe('/topic/hello', function(message){
//			console.log(message)
//		});
//		socket.subscribe('/app/macro', function(message){
//			console.log(message)
//		});
//		socket.client.subscribe('/user/' + userId + '/message', function(message){
//			console.log(message)
//		});
//	}

	$(".logout").on("click",function(e){
		 //询问框
		 indexPageContext.confirm("确定退出吗？", {closeOther:true,ok:function(){
	  		   window.location = window.global.getFinalUrl(window.global.ctx+"/auth/logout");
	  	  }
		 });
	});
	
	indexPageContext.renderUpdatePage = function(layero,data,name,value){
		layero.find("input[name='"+name+"']").attr("oldval",value).val(value);
		tvc.changeDefaultValue(layero.find("input[name='"+name+"']").get(0));
    	layero.find("span[name='"+name+"']").text(value);
	}
	indexPageContext.formInit = function(layero){
		layero.find(".inputElem").mailAutoComplete();
		layero.delegate(".password","keyup change",function(e){
		   var value = $(this).val();
		   var targetname = $(this).attr("targetname");
		   var val = "";
		   val = encryptByAes(value,aesKey);
		   $(layero.find("input[name='"+targetname+"']").get(0)).val(val);
	    }); 
	}
	//个人详情
	$(".selfDetail").on("click",function(e){
		indexPageContext.toUpdate(userId,{title:"个人资料"});
	});
	//修改密码
	$(".selfChangePassword").on("click",function(e){
		indexPageContext.toUpdate(userId,{
			title:"修改密码"
			,successMsg:"修改成功"
			,failMsg:"修改失败"
			,editDivId:"self-password-edit-dialog"
			,url:window.global.ctx+"/auth/account/changepassword"
		});
	});
//	var resizeTimer = null;
//	$(window).on('resize', function () {
//	        if (resizeTimer) {
//	            clearTimeout(resizeTimer)
//	        }
//	        resizeTimer = setTimeout(function(){
//	        	iframeTab.iframeResize();
//				resizeTimer = null;
//	        }, 400);
//	    }
//	);
	//右下角
	$("#rightDownDialog").removeClass("hide");
	layer.open({
	  type: 1,
	  skin: 'demo-class',
	  closeBtn: 1, //不显示关闭按钮
	  shade: false,
	  area: ['340px', '215px'],
	  offset: 'rb', //右下角弹出
	  time: 0, //2秒后自动关闭
	  anim: 2,
	  content:$("#rightDownDialog"), //iframe的url，no代表不显示滚动条
	  end :function(){
		  
	  }
	});
});